<!DOCTYPE html>
<html>
<head>
<#include "/common/freemarker/include_css.ftl">
<#include  "/app/common/uploadimage/attachment.ftl">
<title>活动奖品配置</title>
</head>
 

<body>
	<div class="panel panel-default">
	   <div class="panel-heading">
	       <div class="panel-title">活动奖品配置</div>
	   </div>
	   <div clas="panel-body">
	      <div class="row">
	           <div class="col-md-12">
			   <br>
                
                      
                    <div id="listDiv">
 
                    </div>
 
	           
                 
	        </div>
	    </div>
	</div>
	
 
	<div id="sub-form" class="modal fade" id="myModal" tabindex="-1" role="dialog" 
	   aria-labelledby="myModalLabel" aria-hidden="true" draggable="true">
	   <div class="modal-dialog">
	      <div class="modal-content">            
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
		        <h4 class="modal-title" id="myModalLabel">奖品编辑</h4>
		      </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-sm-12">
						    <div id="editDiv"  >
						        <#assign readOnly=false>
						        <#include  "editSub.ftl"/>
						    </div>
                        </div>
                    </div>        
                </div>
            </div>
        </div>
    </div>
    						    
	<#--  公共js -->
	<#include "/common/freemarker/include_js.ftl">
 
	 <script >
 		<#-- 
	    /* 弹出框拖动,不起作用 */  
		$("#sub-form").draggable({   
		    handle: ".modal-header",   
		    cursor: 'move',   
		    refreshPositions: false  
		});  
		/* center modal */  
		function centerModals() {   
		    $('#sub-form').each(function(i) {   
		        var $clone = $(this).clone().css('display', 'block').appendTo('body'); var top = Math.round(($clone.height() - $clone.find('.modal-content').height()) / 2);   
		        top = top > 0 ? top : 0;   
		        $clone.remove();   
		        $(this).find('.modal-content').css("margin-top", top);   
		    });   
		}   
		$('#sub-form').on('show.bs.modal', centerModals);   
		$(window).on('resize', centerModals);  
		-->

  
	   function listSub(){
	    	   
	 		  $.ajax({
		         type:"GET",
		         url: "<@context/>ued/eventprize3/listSub.do?mainUuid=${param["mainUuid"]}",
		         data:{},
		         cache: false,
		         success: function(html){
		        	   $("#listDiv").html(html);
		         }
	 		 });
	   }
	   
	   $(document).ready(function(){
	   		listSub();
	   })	
 	   function doAdd(){
 	   		editSub(""); 
 	   }
	   function saveSub(){
	    	  var mData = $("#subForm").serialize();
	 		  $.ajax({
		         type:"POST",
		         url: "<@context/>ued/eventprize3/saveSub.do?mainUuid=${param["mainUuid"]}",
		         data:mData,
		         cache: false,
		         success: function(html){
		        	    $("#listDiv").html(html);    	    
			 	   		$(".subData").each(function(){
			 	   			$(this).val("");
			 	   		})
		        	    $('#sub-form').modal('hide');
		          }
	 		 });
	    }
	    
	    function deleteSub(subUuid){
	    	  if (confirm("确定要删除吗？")==false){
	    	  	  return;
	    	  }
	    	  var mData={"subUuid":subUuid };
	 		  $.ajax({
		         type:"POST",
		         url: "<@context/>ued/eventprize3/deleteSub.do?mainUuid=${param['mainUuid']}",
		         data:mData,
		         dataType:"html",
		         cache: false,
		         success: function(html){
		        	   $("#listDiv").html(html);
		          }
	 		 });
	    }
	    
	    function editSub(subUuid){

			 
			  $('#sub-form').modal('show'); 
			  var mData={"subUuid":subUuid };
	 		  $.ajax({
		         type:"GET",
		         url: "<@context/>ued/eventprize3/editSub.do?mainUuid= ${param ['mainUuid']}",
		         data:mData,
		         dataType:"html",
		         cache: false,
		         success: function(html){
		              $("#editDiv").html(html); 
		          }
	 		 });
	    }

	    function moveSub(subUuid,upside){
	         //alert(subUuid);
	    	  var mData={"subUuid":subUuid,"upside":upside };
	 		  $.ajax({
		         type:"POST",
		         url: "<@context/>ued/eventprize3/moveSub.do?mainUuid=${param ['mainUuid']}",
		         data:mData,
		         dataType:"html",
		         cache: false,
		         success: function(html){
		              $("#listDiv").html(html);
		          }
	 		 });
	    }
	</script>
</body>
</html>
 

